15. Exercise: Create an Adapter
Creating an Adapter
In this Exercise, you will get to create an adapter to populate the recyclerview with values.
Exercise Code
Exercise:T03.03-Exercise-RecyclerViewAdapter
Create Adapter
SOLUTION:
- Add a mNumberItems member variable to GreenAdapter.java
- Implement a constructor that sets the mNumberItems variable.
- Make GreenAdapter extend RecyclerView.Adapter with the type parameter of our NumberViewHolder
- Override onCreateViewHolder to return the new ViewHolder and inflate the item Layout
- Override onBindViewHolder and call the bind function in our ViewHolder.
- Override getItemCount to return our mNumberItems variable